<template>
	<view class="goods-list">
		<goods-list :goods="goods"></goods-list>
		<view class="isOver" v-if="isOver">
			-----我是有底线的-----
		</view>
	</view>
</template>

<script>
	import goodsList from '../../components/goodsList/goodsList.vue'
	export default {
		data() {
			return {
				goods:[],
				pageindex:1,
				isOver:false
			}
		},
		components:{
			"goods-list":goodsList
		},
		methods: {
			//获取热门商品数据
			async getGoods(callback){
				const res = await this.$http({url:"/api/getgoods?pageindex="+this.pageindex})
				this.goods = [...this.goods,...res.data.message,];
				callback && callback()
			},
		},
		onLoad() {
			this.getGoods()
		},
		onReachBottom(){
			if(this.goods.length<this.pageindex*10){
				this.isOver=true
			}
			this.pageindex++;
			this.getGoods()
		},
		onPullDownRefresh() {
			this.goods=[]
			this.isOver=false
			this.pageindex=1
			this.getGoods(()=>{
				uni.stopPullDownRefresh()
			})
		}
	}
</script>

<style>
.goods-list{
	background-color: #eee;
}
.isOver{
	width: 100%;
	line-height: 120rpx;
	background-color: #fff;
	font-size: 30rpx;
	text-align: center;
}

</style>
